import React from 'react'

export interface User {
  name: string
  userId: string
}

interface SearchProps {
  param: {
    name: string
    userId: string
  }
  setParam: (param: SearchProps['param']) => void
  user: User[]
}

export const Search = ({ param, setParam, user }: SearchProps) => {
  return (
    <form>
      <div>
        <input
          type="text"
          value={param.name}
          onChange={e => {
            setParam({
              ...param,
              name: e.target.value
            })
          }}
        />
        <select
          value={param.userId}
          onChange={e => {
            setParam({
              ...param,
              userId: e.target.value
            })
          }}
        >
          <option value="">负责人</option>
          {user.map(item => {
            return (
              <option value={item.userId} key={item.userId}>
                {item.name}
              </option>
            )
          })}
        </select>
      </div>
    </form>
  )
}
